package com.gs.synedocket.dialog;

import android.content.Context;
import android.widget.RadioGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.gs.synedocket.R;
import com.gs.synedocket.util.ToastUtil;


public class VersionDialog extends BaseDialog {

    public TextView tvContent;
    private String content;

    public VersionDialog(@NonNull Context context, String content, IDoneListener iDoneListener) {
        super(context, R.style.toast_dialog);
        this.content = content;
        this.iDoneListener = iDoneListener;
    }

    @Override
    public void refreshView() {
    }

    @Override
    public void initView() {
        tvContent = findViewById(R.id.tv_content);
        tvContent.setText(content);
        RadioGroup rgServer = findViewById(R.id.rg_server);
        rgServer.check(R.id.rb_server2);
        findViewById(R.id.btn_cancel).setOnClickListener(v -> dismiss());
        findViewById(R.id.btn_download).setOnClickListener(v -> {
            int buttonId = rgServer.getCheckedRadioButtonId();
            if (buttonId == -1) {
                ToastUtil.showToast(R.string.p_sel_server);
                return;
            }
            if (iDoneListener != null) {
                iDoneListener.getDoneFromDialog(buttonId);
            }
            dismiss();
        });
    }

    @Override
    public int getLayoutId() {
        return R.layout.dialog_version;
    }

    private IDoneListener iDoneListener;

    public interface IDoneListener {
        void getDoneFromDialog(int buttonId);
    }
}
